<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">

    <div class="layui-form-item">
        <label class="layui-form-label">节点名称</label>
        <div class="layui-input-block">
            <input type="text" name="activeNodeName" id="activeNodeName" value="{$model.name}" required="required"
                   lay-verify="flowcode" placeholder="请输入节点名称" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">通过策略</label>
        <div class="layui-input-block">
            <select class="form-control" id="confluence" name="confluence">
                <option value="all" {if condition="($model.confluence eq 'all')" }selected{
                /if}>全部</option>
                <option value="any" {if condition="($model.confluence eq 'any')" }selected{
                /if}>任一</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">审批人类型</label>
        <div class="layui-input-block">
            <select class="form-control" id="selectType" name="selectType" lay-filter="myselect">
                <option value="user" {if condition="($model.type eq 'user')" }selected{/if}>用户</option>
                <option value="role" {if condition="($model.type eq 'role')" }selected{/if}>角色</option>
                <option value="dept" {if condition="($model.type eq 'dept')" }selected{/if}>上级领导</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item" id="spr">
        <label class="layui-form-label">审批人</label>
        <div class="layui-input-block">
            <div id="demo1" class="xm-select-demo"></div>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-user-back-submit" id="LAY-user-back-submit" value="确认">
    </div>
</div>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/admin/js/xm-select.js"></script>
<script>
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$, form = layui.form;
        form.render();
        var select_val = $('#selectType').val();
        my_select(select_val);
        form.on('select(myselect)', function (data) {
            if (data.value == "dept") {
                $('#demo1').val();
                $('#spr').hide();
            } else {
                $('#demo1').val();
                $('#spr').show();
                my_select(data.value);
            }
        });


        function my_select(value) {
            $.ajax({
                url: "{:url('flow/adminTree')}",
                type: 'post',
                dataType: 'json',
                data: {
                    'type': value
                },
                success: function (res) {
                    xmSelect.render({
                        el: '#demo1',
                        filterable: true,
                        data: res
                    })
                }
            });
        }

        form.render();

    })
</script>

